package com.bilibili.sys.service.impl;

import com.bilibili.sys.bean.SysUser;
import com.bilibili.sys.dao.IUserDao;
import com.bilibili.sys.dao.impl.UserDaoImpl;
import com.bilibili.sys.service.IUserService;
import com.bilibili.sys.utils.PageUtils;

import java.util.List;

/**
 * @author alpha
 * @program: BookSystem
 * @description: 1.完成具体的业务处理 2.调用Dao处理数据库的业务
 * @since 2024-03-24 23:41
 **/

public class UserServiceImpl implements IUserService {
    private IUserDao dao = new UserDaoImpl();
    @Override
    public List<SysUser> list(SysUser user) {
        return dao.list(user);
    }

    @Override
    public int save(SysUser entity) {
        return dao.save(entity);
    }

    @Override
    public SysUser findById(int id) {
        return dao.findById(id);
    }

    @Override
    public int updateById(SysUser entity) {
        return dao.updateById(entity);
    }

    @Override
    public int deleteById(int id) {
        return dao.deleteById(id);
    }

/*    @Override
    public  List<SysUser> listPage(PageUtils pageUtils) {
        //return dao.listPage(pageUtils);
        List<SysUser> list = dao.listPage(pageUtils);
        int count = dao.count();
        //封装分页的数据
        pageUtils.setList(list);
        pageUtils.setTotalCount(count);
    }*/
    @Override
    public  void listPage(PageUtils pageUtils) {
        //return dao.listPage(pageUtils);
        List<SysUser> list = dao.listPage(pageUtils);
        int count = dao.count(pageUtils);
        //封装分页的数据
        pageUtils.setList(list);
        pageUtils.setTotalCount(count);
    }

    @Override
    public int count(PageUtils pageUtils) {
        return dao.count(pageUtils);

    }
}
